﻿@model int
@{
    Layout = "";
    ViewBag.Title = "ViewHistory";
}

@*<div class="area">
    <div class="row">

        <div class="col-xs-10">
            <input id="txtCategory" type="text" class="form-control input-sm" placeholder="Tạo nhóm sản phẩm mới">
        </div>
        <div class="col-xs-2" style="padding-left: 0px;">
           
        </div>
    </div>
</div>*@

<input type="hidden" id="historyType" value="@Model" />

<div class="scrollable" style="height: 450px;">
    <div style="padding-bottom: 10px;">
        <table id="historyContent" style="width: 100%;" class="table table-striped table-hover">
            <thead>
                <tr>
                    <th>Thời gian (Ngày/Tháng/Năm)</th>
                    <th>User</th>
                    <th>Hoạt động</th>
                    
                </tr>
            </thead>
            @Html.Action("GetHistoryList", new { type = Model })
        </table>
    </div>
</div>
<div style="width: 100%; text-align: center;">
    <a id="btnLoadMore" href="javascript:;" onclick="loadMore();">Xem thêm</a>
</div>
<script>
    $(document).ready(function () {
        $("#btnLoadMore").data({ page: 1 });

        $(".scrollable").mCustomScrollbar({
            scrollButtons: {
                enable: true
            },
            advanced: {
                updateOnContentResize: true
            },
            theme: "dark-thin"
        });
    });

    function loadMore() {

        var p = $("#btnLoadMore").data('page');
        var historyType = $("#historyType").val();
        $.blockUI();
        $("#btnLoadMore").text("Loading...");
        $.ajax({
            url: "/History/GetHistoryList?pageIndex=" + p + "&type=" + historyType,
            data: {},
            contentType: 'text/html',
            dataType: "html",
            type: "get",
            success: function (data) {

                $("#historyContent tbody").append(data);

                p++;
                $("#btnLoadMore").data({ page: p });
                $.unblockUI();
                $("#btnLoadMore").text("Xem thêm");
            },
            error: function (data) {
                alert("Yêu cầu đăng nhập lại");
                $.unblockUI();
                $("#btnLoadMore").text("Xem thêm");
            }
        });


    }
</script>
